# Python Base Image
FROM python:3.8
RUN echo 'Base image setup completed'

# Environment Variable
ENV PYTHONUNBUFFERED 1
ENV WORKDIR /app
# Make and set working directory
RUN echo 'Making the working directory "/app"'
RUN mkdir ${WORKDIR}

# Set Work Directory
WORKDIR ${WORKDIR}

# Copy the requirement file to working directory
RUN echo 'Copying the requirement file to working directory'
COPY requirements.txt $WORKDIR

RUN pip config set global.index-url http://mirrors.aliyun.com/pypi/simple
RUN pip config set install.trusted-host mirrors.aliyun.com

# Install dependecies with pip
RUN echo 'Installing the dependencies'
RUN pip install -r requirements.txt

RUN apt-get update -y
RUN apt-get install -y libx264-dev python3-opencv mariadb-client

RUN echo 'Copying the project code to working directory'
COPY . $WORKDIR

EXPOSE 5000
RUN python manage.py collectstatic --no-input && python manage.py migrate
# Python execute command
CMD ["gunicorn", "--bind", ":5000", "Daily.wsgi:application"]